<?php
/**
 * 重写用户提器，更改认证方式。
 * DatabaseUserProvider: 默认密码认证， 修改短信验证码认证
 */
namespace App\UserProviders;

use Illuminate\Auth\DatabaseUserProvider;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;

class PhoneCodeProvider extends DatabaseUserProvider
{
    public function validateCredentials(UserContract $user, array $credentials)
    {
        return app('Smscode')->setPhone($user->phone)
            ->setCode($credentials['smscode'])
            ->setType(app('Smscode')->loginType)->verify();
    }
}
